package cn.com.nes.site.controller.contract;

import cn.com.nes.common.web.CommonResult;
import cn.com.nes.site.controller.contract.vo.ContractTypePageVO;
import cn.com.nes.site.controller.contract.vo.ContractTypeQueryVO;
import cn.com.nes.site.service.contract.ContractTypeService;
import cn.com.nes.site.service.contract.bo.ContractTypeQueryBO;
import cn.com.nes.site.service.contract.dto.ContractTypeDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = {"合同管理-合同类型"})
@Controller
@RequestMapping("/v2/contract/type")
public class ContractTypeController {

    @Resource
    private ContractTypeService contractTypeService;

    @ApiOperation(value = "查询合同类型列表-分页")
    @RequestMapping(value = "/getContractTypePage", method = RequestMethod.GET)
    public @ResponseBody CommonResult<ContractTypeDTO> getContractPage(
            ContractTypePageVO contractTypePageVO) throws Exception {
        Page<ContractTypeDTO> page = contractTypeService.getContractTypePage(contractTypePageVO.convertToBo());
        return CommonResult.page(page);
    }

    @ApiOperation(value = "查询合同类型列表")
    @RequestMapping(value = "/getContractTypes", method = RequestMethod.GET)
    public @ResponseBody CommonResult<ContractTypeDTO> getContractTypes(ContractTypeQueryVO contractTypeQueryVO) throws Exception {
        List<ContractTypeDTO> records = contractTypeService.getContractTypes(contractTypeQueryVO.convertToBo(ContractTypeQueryBO.class));
        return CommonResult.page(records);
    }

}
